﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    class Object2D
    {
        private Vector2 position;
        /// <summary>
        /// Used to position the object
        /// </summary>
        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        private Rectangle sourceRectangle;
        /// <summary>
        /// area da imagem a ser desenhada
        /// </summary>
        public Rectangle SourceRectangle
        {
            get { return sourceRectangle; }
            set { sourceRectangle = value; }
        }

        private Color cor;
        /// <summary>
        /// tom que coloca por cima da imagem
        /// </summary>
        public Color Cor
        {
            get { return cor; }
            set { cor = value; }

        }

        private float rotation;
        /// <summary>
        /// rotação do seu objeto
        /// </summary>
        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }

        }

        private Vector2 origin;
        /// <summary>
        /// ponto em que os valores vão ser aplicados
        /// </summary>
        public Vector2 Origin
        {
            get { return origin; }
            set { origin = value; }

        }

        private Vector2 scale;
        /// <summary>
        /// escala do objeto
        /// </summary>
        public Vector2 Scale
        {
            get { return scale; }
            set { scale = value; }

        }

        private SpriteEffects effects;
        /// <summary>
        /// efeito aplicado no seu objeto, inverter horizontalmente ou verticalmente
        /// </summary>
        public SpriteEffects Effects
        {
            get { return effects; }
            set { effects = value; }

        }

        private float layerDepth;
        /// <summary>
        /// profundidade da imagem exibida
        /// </summary>
        public float LayerDepth
        {
            get { return layerDepth; }
            set { layerDepth = value; }

        }

        private Texture2D texture;
        /// <summary>
        /// representação gráfica do objeto
        /// </summary>
        public Texture2D Texture
        {
            get { return texture; }
            set { texture = value; }
        }

        public Object2D(){}


        /// <summary>
        /// Construtor do objeto
        /// </summary>
        /// <param name="texture">Used to define the objects texture</param>
        public Object2D(Texture2D texture)
        {

            position = new Vector2(0, 0);
            this.texture = texture;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="position"></param>
        public Object2D(Texture2D texture, Vector2 position)
        {

            this.position = position;
            this.texture = texture;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="sourceRectangle"></param>
        public Object2D(Texture2D texture, Rectangle sourceRectangle)
        {
            this.sourceRectangle = sourceRectangle;
            cor = Color.White;
            rotation = 0f;
            origin = new Vector2(0, 0);
            scale = new Vector2(1, 1);

            position = new Vector2(0, 0);
            this.texture = texture;
        } 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="sourceRectangle"></param>
        public Object2D(Texture2D texture, Rectangle sourceRectangle, Vector2 position)
        {
            this.sourceRectangle = sourceRectangle;
            cor = Color.White;
            rotation = 0f;
            origin = new Vector2(0, 0);
            scale = new Vector2(1, 1);

            this.position = position;
            this.texture = texture;
        }

        public virtual void Load(ContentManager Content)
        {
            
            this.sourceRectangle = new Rectangle(0,0,0,0);
            cor = Color.White;
            rotation = 0f;
            origin = new Vector2(0, 0);
            scale = new Vector2(1, 1);
            position = new Vector2(0, 0);
            
        }

        /// <summary>
        /// The Code to alter the object in any way should go inside this function
        /// </summary>
        public virtual void Update()
        {

        }

        /// <summary>
        /// Function used to display object on the screen
        /// </summary>
        /// <param name="spriteBatch">Needed to do actual drawing</param>
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, position, sourceRectangle, cor, rotation, origin, scale, effects, layerDepth);
        }

    }

}